package com.agan.agangame.controller;

import java.util.Arrays;
import java.util.Map;

import cn.hutool.json.JSONUtil;
import com.agan.agangame.dto.BaseResp;
import com.agan.agangame.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.agan.agangame.entity.CiyuEntity;
import com.agan.agangame.service.CiyuService;




/**
 * 
 *
 * @author cg
 * @email 
 * @date 2020-08-15 00:36:10
 */
@RestController
@RequestMapping("agangame/ciyu")
public class CiyuController {
    @Autowired
    private CiyuService ciyuService;

    /**
     * 列表
     */
    @GetMapping("/list")
    public BaseResp<String> list(){
        BaseResp<String> result = BaseResp.buildSuccess();
        CiyuEntity ciyuEntity = ciyuService.queryPage();
        JSONUtil.parseObj(ciyuEntity);
        result.setData(JSONUtil.parseObj(ciyuEntity).getStr("name"));
        return result;
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
		CiyuEntity ciyu = ciyuService.getById(id);

        return R.ok().put("ciyu", ciyu);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody CiyuEntity ciyu){
		ciyuService.save(ciyu);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody CiyuEntity ciyu){
		ciyuService.updateById(ciyu);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
		ciyuService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
